package vuelta.general.rss;


import vuelta.general.GiroItaliaActivity;
import vuelta.general.R;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import appReate.tab.PageIndicator;
import appReate.tab.TestFragmentAdapter;
import appReate.tab.TestTitleFragmentAdapter;
import appReate.tab.TitlePageIndicator;

public class RssActivity extends FragmentActivity {

	TestFragmentAdapter mAdapter;
	ViewPager mPager;
	PageIndicator mIndicator;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.simple_titles);
		initToolbar();

		mAdapter = new TestTitleFragmentAdapter(getSupportFragmentManager(), getApplicationContext());

		mPager = (ViewPager) findViewById(R.id.pager);
		mPager.setAdapter(mAdapter);

		mIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
		mIndicator.setViewPager(mPager);
	}
	
	protected void initToolbar() {
		LinearLayout fidatyToolbar = (LinearLayout) findViewById(R.id.home_toolbar);
		if (fidatyToolbar != null) {
			LinearLayout mHomeToolbarLayout = (LinearLayout) findViewById(R.id.home_layout);

			ImageButton homeButton = (ImageButton) mHomeToolbarLayout.findViewById(R.id.home_button);
			homeButton.setOnClickListener(new OnClickListener() {

				public void onClick(View v) {
					Intent intent = new Intent(RssActivity.this, GiroItaliaActivity.class);
					startActivity(intent);
					finish();
				}

			});
		}
	}
}